Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Valid the authorized nodes in the node shared secret #715

Conversation

tenmoves
Copy link
Contributor

@tenmoves tenmoves commented Nov 24, 2022

Description

Actually during the pending validation, we control if the new authorized nodes in the node shared secret transaction are part of the candidate, but we do not verify if the selected ones are the good ones.
We should not verify if the new authorized nodes are part of the candidate, but directly verify that all authorized nodes are the same as the return of the function NodeRenewal.next_authorized_node_public_keys()

Fixes #694

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

we make sure that the authorized nodes in the transaction are exactly the same as the ones returned by
next_authorized_node_public_keys function

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@tenmoves tenmoves added bug Something isn't working shared secrets Involve SharedSecrets labels Nov 24, 2022
@tenmoves tenmoves self-assigned this Nov 24, 2022
@tenmoves tenmoves marked this pull request as ready for review November 25, 2022 09:40
Enum.all?(
Map.keys(authorized_keys),
&Utils.key_in_node_list?(nodes, &1)
authorized_keys
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it will be more clear without the pipeline by extracting variables and do simple comparison.

@samuelmanzanera samuelmanzanera added the core team Assigned to the core team label Nov 28, 2022
&Utils.key_in_node_list?(nodes, &1)
) do
{:ok, _, _} <- NodeRenewal.decode_transaction_content(content),
true <- sorted_authorized_keys == sorted_node_renewal_authorized_keys do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may add a unit test to ensure the error when both list are different.
Otherwise it works well 👍

@samuelmanzanera samuelmanzanera merged commit 9ae0275 into archethic-foundation:develop Nov 30, 2022
tenmoves added a commit to tenmoves/archethic-node that referenced this pull request Dec 6, 2022
…ation#715)

* Valid the authorized nodes in the node shared secret

* refactoring

* added test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working core team Assigned to the core team shared secrets Involve SharedSecrets
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Valid the authorized nodes in the node shared secret
3 participants